package com.lagou.service.impl;

import com.lagou.dao.AuthCodeDao;
import com.lagou.pojo.AuthCode;
import com.lagou.service.AuthCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service
@Transactional
public class AuthCodeServiceImpl implements AuthCodeService {

    @Autowired
    private AuthCodeDao authCodeDao;

    @Override
    public boolean isRightAuthCode(String email, String code) {
        List<AuthCode> authCodeList = authCodeDao.findByJpql(email, code, new Date());
        if (authCodeList != null && !authCodeList.isEmpty()) {
            return true;
        }
        return false;
    }
}
